import { parseTime } from 'utils'

/**
 * [handleDownload description]
 * @param  {[arr]} tHeader           [表格头部]
 * @param  {[arr]} filterVal         [表格对应字段]
 * @param  {[json]} multipleSelection [表格数据]
 * @param  {[fun]} formatJson         [format方法]
 * @return {[viod]}                   [无返回]
 */
function handleDownload(tHeader,filterVal,multipleSelection,formatJson) {
    require.ensure([], () => {
      const { export_json_to_excel } = require('vendor/Export2Excel')
      tHeader = ['订单号', '资金方', '经销商', '业务员', '汽车车型','车架号','打款日期','垫资周期','预计到期日','截止日期','总天数',
      '系统计算服务费天数','服务费是否异常','是否逾期','逾期天数','采购总价格','定金金额','垫资金额','保证金','服务费比率','服务费2比率',
      '服务费','服务费2','应收款金额','已回款金额','待回款金额','订单状态']
      filterVal = ['orderNumber', 'funderName', 'dealerName', 'businessName', 'carName','vin', 'orderRemitStartTime', 'maximum', 'expectedFinishDate', 'nowDate'
      , 'sumDay', 'interestDay', 'isInterest', 'isOver', 'overDay', 'totalPrice', 'earnest', 'paymentAmount','deposit','interestRate','overInterestRate','interest','exceed',
      'allPrice','totalReturnPrice','returnMoney','status']
      const list = multipleSelection
      formatJson?const data = formatJson(filterVal, list):const data =list;
      export_json_to_excel(tHeader, data, '列表excel')
    })
};

/*function formatJson(filterVal, jsonData) {
  return jsonData.map(v => filterVal.map(j => {
    if (j === 'orderRemitStartTime') {
      return parseTime(v[j])
    } else {
      return v[j]
    }
  }))
};*/

export default handleDownload;